//
//  PostViewController.m
//  CaoShi
//
//  Created by aa on 2018/4/20.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXPostViewController.h"
#import "YXWebViewController.h"
#import <GoogleMobileAds/GoogleMobileAds.h>
#import "YXPostListCell.h"
#import <SDCycleScrollView.h>

@interface YXPostViewController ()<UITableViewDataSource,UITableViewDelegate,SDCycleScrollViewDelegate>
//新建一个属性
@property (nonatomic, strong) GADBannerView *bView;
@property (nonatomic ,strong) UITableView *tableView;
@property (nonatomic ,strong) SDCycleScrollView *cycleScrollView;
@property (nonatomic ,strong) NSArray *bannerArr;

@end

@implementation YXPostViewController

- (NSArray *)bannerArr {
    if (!_bannerArr) {
        _bannerArr = @[@"jiazheng_img",@"jiazheng_img",@"jiazheng_img"];
    }
    return _bannerArr;
}


- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, ISiPhoneX?88:64, kScreenWidth, kScreenHeight) style:(UITableViewStylePlain)];
        _tableView.backgroundColor = color_backColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

        UIView *headerView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, kScreenWidth, 200))];
        headerView.backgroundColor = [UIColor py_colorWithHexString:@"#f2f2f2"];
        self.tableView.tableHeaderView = headerView;
        
        _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:(CGRectMake(0, 0, kScreenWidth, 200)) delegate:self placeholderImage:[UIImage imageNamed:@""]];
        _cycleScrollView.localizationImageNamesGroup = self.bannerArr;
        [headerView addSubview:self.cycleScrollView];
        
        [_tableView registerNib:[UINib nibWithNibName:@"YXPostListCell" bundle:nil] forCellReuseIdentifier:@"YXPostListCell"];
    }
    return _tableView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"发帖";
    
    [self setNavUI];
    
}

- (void)setNavUI {
    WZHNavBarItem *item = [WZHNavBarItem itemWithTitle:@"说明" target:self action:@selector(clickItem)];
    item.textFont = [UIFont systemFontOfSize:12];
    item.textColor = color_blueColor;
    self.w_navRightBarButtonItem = item;
    
    [self.view addSubview:self.tableView];
    
    _bView = [[GADBannerView alloc] initWithFrame:CGRectMake(0, ISiPhoneX?88:64, self.view.frame.size.width, 50)];
    //这个就是你添加的广告单元的ID
    _bView.adUnitID = @"广告ID";
    _bView.rootViewController = self;
    GADRequest *request = [GADRequest request];
    
    //如果是开发阶段，需要填写测试手机的UUID，不填写可能会误会你自己刷展示量
    request.testDevices = @[@"测试设备的UUID"];
    
    [_bView loadRequest:request];
    [self.view addSubview:self.bView];
    
}

- (void)clickItem {
    
  
}


#pragma mark - UITableView Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kScreenWidth * 60 / 375;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YXPostListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YXPostListCell" forIndexPath:indexPath];
    return cell;
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
